package logic

import (
	"HD_running/mall/order/api/model"
	"context"

	"HD_running/mall/order/api/internal/svc"
	"HD_running/mall/order/api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type ResuleproLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewResuleproLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ResuleproLogic {
	return &ResuleproLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *ResuleproLogic) Resulepro(req *types.ResultReq) (resp *types.ResultResp, err error) {
	// todo: add your logic here and delete this line
	_, err = l.svcCtx.ResultproModel.Insert(l.ctx, &model.Resultpro{
		Date1: req.Date1,
		Sno:   req.Sno,
		Resqu: req.Resqu,
	})
	if err != nil {
		return &types.ResultResp{Msg: "账号已被注册"}, nil
	}

	return &types.ResultResp{Msg: "插入成功"}, nil
}
